home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / rlib / logspace < prev    next >
Text File  |  1994-09-23  |  755b  |  33 lines

  1. //-------------------------------------------------------------------//
  2. //
  3. //  Syntax:    logspace ( L1 , L2 )
  4. //        logspace ( L1 , L2 , n )
  5.  
  6. //  Description:
  7.  
  8. //  Generate a logarithmically spaced vector. logspace(L1, L2)
  9. //  generates a vector of 50 points, logarithmically spaced between
  10. //  decades 10^L1 and 10^L2.
  11.  
  12. //  Logspace(L1, L2, N) generates N points.
  13.  
  14. //  If L2 is pi, then the generated values are between 10^L1 and pi. 
  15. //-------------------------------------------------------------------//
  16.  
  17. logspace = function(d1, d2, n) 
  18. {
  19.   global (pi)
  20.  
  21.   if(!exist (n)) { n = 50; }
  22.  
  23.   if(d2 == pi) { 
  24.     D2 = log10 (pi); 
  25.   else
  26.     D2 = d2;
  27.   }
  28.  
  29.   if (n < 2) { error ("logspace: N must be >= 2"); }
  30.  
  31.   return (10).^ [d1+(0:n-2)*(D2-d1)/(n-1), D2]; 
  32. };
  33.